package com.tanglon.controller;

import com.tanglon.annotation.BlogLog;
import com.tanglon.domain.ResponseResult;
import com.tanglon.domain.dto.RegisterDTO;
import com.tanglon.domain.dto.UserInfoDTO;
import com.tanglon.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @GetMapping("/userInfo")
    @BlogLog(businessName = "获取用户信息")
    public ResponseResult userInfo(){
        return userService.userInfo();
    }

    @PutMapping("/userInfo")
    @BlogLog(businessName = "更新用户信息")
    public ResponseResult updateUserInfo(@RequestBody UserInfoDTO userInfoDTO){
        return userService.updateUserInfo(userInfoDTO);
    }

    @PostMapping("/register")
    @BlogLog(businessName = "用户注册")
    public ResponseResult register(@RequestBody RegisterDTO registerDTO){
        return userService.register(registerDTO);
    }
}
